{template 'common/header'}
{template 'common'}

<script type="text/javascript" src="resource/js/lib/jquery-ui-1.10.3.min.js"></script>
<ul class="nav nav-tabs">
	<li {if $operation == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('oldhouse', array('op' => 'post'))}">添加二手房</a></li>
	<li {if $operation == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('oldhouse', array('op' => 'display'))}">管理员发布</a></li>
	<li {if $operation == 'displaymember'}class="active"{/if}><a href="{php echo $this->createWebUrl('oldhouse', array('op' => 'displaymember'))}">中介发布</a></li>
	<li {if $operation == 'displaycheck'}class="active"{/if}><a href="{php echo $this->createWebUrl('oldhouse', array('op' => 'displaycheck'))}">待审核</a></li>

	
</ul>
{if $operation == 'post'} 
<link type="text/css" rel="stylesheet" href="../addons/ewei_shopping/images/uploadify_t.css" />
<style type='text/css'>
	.tab-pane {padding:20px 0 20px 0;}
</style>
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" id="form1" onsubmit='return formcheck()'>
		<div class="panel panel-default">
			<div class="panel-heading">
				{if empty($item['id'])}添加二手房{else}编辑二手房{/if}
			</div>
			<div class="panel-body">
				
				<div class="tab-content">
					<div class="tab-pane  active" id="tab_basic">{template 'oldhouse_basic'}</div>
					
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>

<script type="text/javascript">
	var category = {php echo json_encode($children)};

	$(function () {
		window.optionchanged = false;
		$('#myTab a').click(function (e) {
			e.preventDefault();//阻止a链接的跳转行为
			$(this).tab('show');//显示当前选中的链接及关联的content
		})
	});

	function formcheck(){
	
		if($("#title").isEmpty()) {
			util.message("请输入标题");
			return false;
		}
		
		if($("#saleprice").isEmpty()) {
			util.message("请输入二手房销售价格");
			return false;
		}
		if($("#perprice").isEmpty()) {
			util.message("请输入二手房均价");
			return false;
		}
		
		if($("#housestyle").val() == 0) {
			util.message("请选择二手房户型");
			return false;
		}
		if($("#houseareaid").val() == 0) {
			util.message("请选择所属地区");
			return false;
		}
		
		
		if($("#area").isEmpty()) {
			util.message("请输入面积");
			return false;
		}
		if($("#floor").isEmpty()) {
			util.message("请输入楼层");
			return false;
		}
		if($("#direction").isEmpty()) {
			util.message("请输入朝向");
			return false;
		}
		if($("#decorate").val() ==0) {
			util.message("请选择装修");
			return false;
		}
		if($("#year").isEmpty()) {
			util.message("请输入年代");
			return false;
		}
		if($("#name").isEmpty()) {
			util.message("请输入房东(中介)姓名");
			return false;
		}
		if($("#tel").isEmpty()) {
			util.message("请输入房东(中介)电话");
			return false;
		}
		if($("#housearea").isEmpty()) {
			util.message("请输入小区");
			return false;
		}
       if($("#address").isEmpty()) {
			util.message("请输入地址");
			return false;
		}
		
		if($("#productspecial").isEmpty()) {
		//	util.message("请输入项目特色");
		//	return false;
		}
		
		if($("#housestatus").value()) {
			util.message("请选择楼盘状态");
			return false;
		}
	
		
		var content = $("textarea[name='content']").val();

		if (content == '') {
			util.message("请输入详情");
			return false;
		}
		
		
		
		var full = checkoption();
		if(!full){return false;}
	
		return true;
	}
	
	function checkoption(){
		
		var full = true;
		if( $("#hasoption").get(0).checked){
			$(".spec_title").each(function(i){
				if( $(this).isEmpty()) {
					$('#myTab a[href="#tab_option"]').tab('show');
					Tip.focus(".spec_title:eq(" + i + ")","请输入规格名称!","top");
					full =false;
					return false;
				}
			});
			$(".spec_item_title").each(function(i){
				if( $(this).isEmpty()) {
					$('#myTab a[href="#tab_option"]').tab('show');
					Tip.focus(".spec_item_title:eq(" + i + ")","请输入规格项名称!","top");
					full =false;
					return false;
				}
			});
		}
		if(!full) { return false; }
		return full;
	}

</script>

{elseif $operation == 'display'}

<div class="main">
	<div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
			<input type="hidden" name="m" value="weixinmao_house" />
			<input type="hidden" name="do" value="oldhouse" />
			<input type="hidden" name="op" value="display" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-xs-8 col-sm-8 col-lg-9">
					<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}">
					
				</div>
					<div class="col-xs-4 col-sm-2 col-lg-2">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
		
		</form>
	</div>
</div>
<style>
.label{cursor:pointer;}
</style>
<div class="panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:5%;">ID</th>
					<th style="width:10%;">城市</th>
					<th style="width:10%;">地区</th>
					<th style="width:10%;">标题</th>
					<th style="width:10%;">二手房类型</th>
					<th style="width:10%;">二手房户型</th>
					<th style="width:10%;">二手房售价</th>
					<th style="width:10%;">二手房均价</th>
					<th style="width:10%;">创建时间</th>
					<th style="width:5%;">是否推荐</th>
					<th style="width:5%;">状态</th>
					<th style="width:5%;">排序</th>
					<th style="text-align:right; width:20%;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
					<td>{$item['id']}</td>
					<td>{$item['cityname']}</td>
					<td>{$item['areaname']}</td>
					<td>{$item['title']}</td>
					<td>{$item['housetypename']}</td>
					<td>{$item['housestyle']}</td>
				    <td>{$item['saleprice']}万</td>
					<td>{$item['perprice']}元/㎡</td>
					<td>{$item['areaname']}</td>
					<td>{php echo date('Y-m-d',$item['createtime']);}</td>
					<td>
					{if $item['isrecommand']==1}
								<span class='label label-success'>是</span>
								{else}
								<span class='label label-danger'>否</span>
								{/if}
					</td>
					<td>
					{if $item['status']==0}
								<span class='label label-success'>已上架</span>
								{else}
								<span class='label label-danger'>已下架</span>
								{/if}
					</td>
					<td>{$item['sort']}	</td>
					<td style="text-align:right;">
						<a href="{php echo $this->createWebUrl('oldhouse', array('id' => $item['id'], 'op' => 'post'))}"class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="编辑"><i class="fa fa-pencil"></i></a>&nbsp;&nbsp;
						<a href="{php echo $this->createWebUrl('oldhouse', array('id' => $item['id'], 'op' => 'delete'))}" onclick="return confirm('此操作不可恢复，确认删除？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
	</div>
</div>

{elseif $operation == 'displaymember'}

<div class="main">
	<div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
			<input type="hidden" name="m" value="weixinmao_house" />
			<input type="hidden" name="do" value="oldhouse" />
			<input type="hidden" name="op" value="displaymember" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-xs-8 col-sm-8 col-lg-9">
					<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}">
					
				</div>
					<div class="col-xs-4 col-sm-2 col-lg-2">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
		
		</form>
	</div>
</div>
<style>
.label{cursor:pointer;}
</style>
<div class="panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:5%;">ID</th>
					<th style="width:10%;">城市</th>
					<th style="width:10%;">地区</th>
					<th style="width:10%;">标题</th>
					<th style="width:10%;">二手房类型</th>
					<th style="width:10%;">二手房户型</th>
					<th style="width:10%;">联系人</th>
					<th style="width:10%;">电话</th>
					<th style="width:10%;">创建时间</th>
					<th style="width:5%;">是否推荐</th>
					<th style="width:5%;">状态</th>
					<th style="width:5%;">排序</th>
					<th style="text-align:right; width:20%;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
					<td>{$item['id']}</td>
					<td>{$item['cityname']}</td>
					<td>{$item['areaname']}</td>
					<td>{$item['title']}</td>
					<td>{$item['housetypename']}</td>
					<td>{$item['housestyle']}</td>
				    <td>{$item['name']}</td>
					<td>{$item['tel']}</td>
					<td>{php echo date('Y-m-d',$item['createtime']);}</td>
					<td>
					{if $item['isrecommand']==1}
								<span class='label label-success'>是</span>
								{else}
								<span class='label label-danger'>否</span>
								{/if}
					</td>
					<td>
					{if $item['status']==0}
								<span class='label label-success'>已上架</span>
								{else}
								<span class='label label-danger'>已下架</span>
								{/if}
					</td>
					<td>{$item['sort']}	</td>
					<td style="text-align:right;">
						<a href="{php echo $this->createWebUrl('oldhouse', array('id' => $item['id'], 'op' => 'post'))}"class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="编辑"><i class="fa fa-pencil"></i></a>&nbsp;&nbsp;
						<a href="{php echo $this->createWebUrl('oldhouse', array('id' => $item['id'], 'op' => 'delete'))}" onclick="return confirm('此操作不可恢复，确认删除？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
	</div>
</div>

{elseif $operation == 'displaycheck'}

<div class="main">
	<div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
			<input type="hidden" name="m" value="weixinmao_house" />
			<input type="hidden" name="do" value="oldhouse" />
			<input type="hidden" name="op" value="displaycheck" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-xs-8 col-sm-8 col-lg-9">
					<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}">
					
				</div>
					<div class="col-xs-4 col-sm-2 col-lg-2">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>
		
		</form>
	</div>
</div>
<style>
.label{cursor:pointer;}
</style>
<div class="panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:5%;">ID</th>
					<th style="width:10%;">城市</th>
					<th style="width:10%;">地区</th>
					<th style="width:10%;">标题</th>
					<th style="width:10%;">二手房类型</th>
					<th style="width:10%;">二手房户型</th>
					<th style="width:10%;">联系人</th>
					<th style="width:10%;">电话</th>
					<th style="width:10%;">创建时间</th>
					<th style="width:5%;">是否推荐</th>
					<th style="width:5%;">排序</th>
					<th style="text-align:right; width:20%;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
					<td>{$item['id']}</td>
					<td>{$item['cityname']}</td>
					<td>{$item['areaname']}</td>
					<td>{$item['title']}</td>
					<td>{$item['housetypename']}</td>
					<td>{$item['housestyle']}</td>
				    <td>{$item['name']}</td>
					<td>{$item['tel']}</td>
					<td>{php echo date('Y-m-d',$item['createtime']);}</td>
					<td>
					{if $item['isrecommand']==1}
								<span class='label label-success'>是</span>
								{else}
								<span class='label label-danger'>否</span>
								{/if}
					</td>
					
					<td>{$item['sort']}	</td>
					<td style="text-align:right;">
					<a href="{php echo $this->createWebUrl('oldhouse', array('id' => $item['id'], 'op' => 'done'))}" onclick="return confirm('此操作不可恢复，确认完成服务？');"
						   class="btn btn-primary" data-toggle="tooltip" data-placement="bottom" title="审核通过">审核通过</a>
						<a href="{php echo $this->createWebUrl('oldhouse', array('id' => $item['id'], 'op' => 'post'))}"class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="编辑"><i class="fa fa-pencil"></i></a>&nbsp;&nbsp;
						<a href="{php echo $this->createWebUrl('oldhouse', array('id' => $item['id'], 'op' => 'delete'))}" onclick="return confirm('此操作不可恢复，确认删除？');return false;" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
	</div>
</div>





{/if}
{template 'common/footer'}
